Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

152
Visualizações
React Native (React Navigation)<> Firebase login screen

I'm using Firebase to keep track of all the users. I was able to connect Firebase. User registration is working fine.

I'm having issues with logging the users. When I enter login and password, the app doesn't redirect me to the right screen, and also throws this warning [Unhandled promise rejection: TypeError: navigation.navigation is not a function. (In 'navigation.navigation("myProfile")', 'navigation.navigation' is undefined)]

Here is how I do it

import { useNavigation } from "@react-navigation/native";
import React, { useEffect, useState } from "react";
import { View, ...} from "react-native";
import { auth } from "../firebase";

const Profile = () => {
  const [email, setEmail] = useState("");
  const [password, setPassword] = useState("");

  const navigation = useNavigation();

   useEffect(() => {
     const unsubscribe = auth.onAuthStateChanged((user) => {
       if (user) {
         navigation.navigation("myProfile");
       }
     });
     return unsubscribe;
   }, []);


  const signIn = () => {
    auth
      .signInWithEmailAndPassword(email, password)
      .then((userCredentials) => {
        const user = userCredentials.user;
        console.log("Sign In user.email = " + user.email);
      })
      .catch((error) => alert(error.message));
  };
//more code 

I also tried this, but it didn't help

import React, { useEffect, useState } from "react";
import { View, ...} from "react-native";
import { auth } from "../firebase";

const Profile = ({navigation}) => {
  const [email, setEmail] = useState("");
  const [password, setPassword] = useState("");
    
   useEffect(() => {
     const unsubscribe = auth.onAuthStateChanged((user) => {
       if (user) {
         navigation.navigation("myProfile");
       }
     });
     return unsubscribe;
   }, []);

//more code 

I'm not sure if I need to navigation.navigation("myProfile") onPress or it has to be inside of the the useEffect

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Use

navigation.navigate("myProfile")

instead of

navigation.navigation("myProfile");

Also you can destruct your hook object like this

const { navigate } = useNavigation()

in order to just write

navigate("myProfile")

I'm not sure if I need to navigation.navigation("myProfile") onPress or it has to be inside of the the useEffect

Most of the cases you should move the user to home screen (logged in user screen) when the signIn function returns true and the user is logged in, so in this case I think you have to use navigate("myProfile") inside of

auth
  .signInWithEmailAndPassword(email, password)
  .then((userCredentials) => {
    ...your code
    navigation.navigate("myProfile")
  })
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda